package com.sgcc.ln.pmos.e_ln_home.activity;

import android.os.Build;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.sgcc.pmos.nativesdk.R;
import com.sgcc.ln.pmos.arouter.home.HomeArouterPath;
import com.sgcc.ln.pmos.common.base.BaseActivity;
import com.sgcc.ln.pmos.common.widget.TitleBar;

/**
 *
 */
@Route(path = HomeArouterPath.HOME_INFOSHOWWEB)
public class InfoShowWebActivity extends BaseActivity {

    private TitleBar mTitleBar;
    private WebView mWvContent;

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.activity_infoshowweb;
    }

    @Override
    protected void initViews() {
        super.initViews();
        String fileId = getIntent().getStringExtra("fileId");
        mTitleBar = (TitleBar) findViewById(R.id.title_bar);
        mWvContent = (WebView) findViewById(R.id.wv_content);
//        String webUrl = "https://pmos.ln.sgcc.com.cn/px-settlement-infpubmeex/fileService/preview?fileId=" + fileId + "#toolbar=0";
        String webUrl = "https://www.baidu.com";
        /**
         * 通过此WebView 获取到 WebSettings ，通过WebSettings设置WebView
         */
        WebSettings webSettings = mWvContent.getSettings();

        /**
         * 设置支持JavaScript激活，可用等
         */
        webSettings.setJavaScriptEnabled(true);
        webSettings.setDomStorageEnabled(true);
        webSettings.setBlockNetworkImage(false);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
        }

        /**
         * 设置自身浏览器，注意：可用把WebView理解为浏览器
         * 设置setWebViewClient(new WebViewClient());后，手机就不会跳转其他的浏览器
         */
        mWvContent.setWebViewClient(new WebViewClient());

        mWvContent.loadUrl(webUrl);
    }
}
